﻿//TODO: NOR: Test

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// NORs two images.
    /// </summary>
    public class NOR : BaseImageFilter, ITwoSourceFilter
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NOR"/> class.
        /// </summary>
        public NOR()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="NOR"/> class.
        /// </summary>
        /// <param name="_nor">The _nor.</param>
        internal NOR(NOR _nor)
        {
        }

        /// <summary>
        /// Execute this Filter
        /// A Debug Statement is written if a concrete Filter is called
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            Process((UnsafeBitmap)_bitmap.Clone(), _bitmap);
            return _bitmap;
        }

        /// <summary>
        /// Processes the specified bmpimg.
        /// </summary>
        /// <param name="_bitmap1"></param>
        /// <param name="_bitmap2"></param>
        /// <returns></returns>
        public UnsafeBitmap Process(UnsafeBitmap _bitmap1, UnsafeBitmap _bitmap2)
        {
            // NANDing of 2 images is done by ANDing 2 images then negating the resultant

            UnsafeBitmap orimg = new OR().Process(_bitmap1, _bitmap2);
            new Invert().Execute(orimg);
            return orimg;
        }

        /// <summary>
        /// This is used to clone a filter, each filter must implement it's own clone functionality
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new NOR(this);
        }
    }
}
